<template>
  <div class="info" v-loading="loading">
    <div class="card_con mb15">
      <el-row class="mb15">
        <el-col :span="5" class="pr40">
          <div class="fz14 mb15">酒店名：</div>
          <el-input
            v-model="orderId"
            clearable
            placeholder="请输入酒店名"
          ></el-input>
        </el-col>
        <el-col :span="4">
          <div class="fz14 mb15">&nbsp;</div>
          <el-button type="primary" @click="handleQuery">查询</el-button>
        </el-col>
      </el-row>
    </div>
    <div class="card_con">
      <el-table
        border
        :data="tableData"
        :header-cell-style="{
          'text-align': 'center',
        }"
        :cell-style="{ 'text-align': 'center' }"
        style="width: 100%"
        highlight-current-row
      >
        <!-- <el-table-column type="selection" min-width="15%"> </el-table-column> -->
        <el-table-column prop="id" label="商家id" min-width="15%">
        </el-table-column>
        <el-table-column prop="mch_name" label="商家名" min-width="15%">
        </el-table-column>
        <el-table-column prop="name" label="酒店名" min-width="25%">
        </el-table-column>
        <el-table-column label="缩略图" min-width="15%">
          <template slot-scope="scope">
            <div class="slt" v-if="scope.row.thumb">
              <el-popover placement="right" width="200" trigger="hover">
                <img class="tbImg1" :src="scope.row.thumb" alt="" />
                <img
                  class="tbImg"
                  slot="reference"
                  :src="scope.row.thumb"
                  alt=""
                />
              </el-popover>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="star" label="星级" min-width="20%">
        </el-table-column>

        <el-table-column label="酒店信息" min-width="25%">
          <template slot-scope="scope">
            <div class="hotel_info">
              <div>装修时间：{{ scope.row.base.renovation }}</div>
              <div>开业时间：{{ scope.row.base.open }}</div>
              <div>酒店星级：{{ scope.row.base.level }}</div>
              <div>房间数量：{{ scope.row.base.rooms }}</div>
              <div>酒店电话：{{ scope.row.base.tel }}</div>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="操作" min-width="20%">
          <template slot-scope="scope">
            <div class="caozuo">
              <div
                class="handleExamine hand_cs"
                @click="handleDetail(scope.row)"
              >
                查看房型
              </div>
              <div class="handleEdit hand_cs" @click="handleEdit(scope.row)">
                编辑
              </div>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination">
        <Pagination :page="page" @onCurrentChange="handleCurrentChange" />
      </div>
      <el-dialog
        class="editDialog"
        title="房型"
        :visible.sync="dialogVisible"
        width="80%"
      >
        <Detail v-if="dialogVisible" :rowData="rowData"></Detail>
      </el-dialog>
      <el-dialog
        class="editDialog"
        :title="title"
        :visible.sync="editDialog"
        width="50%"
      >
        <Edit
          v-if="editDialog"
          :rowData="rowData"
          @handleClose="handleClose"
        ></Edit>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import Pagination from "@/components/Pagination.vue";
import Detail from "./hotelRoom.vue";
import Edit from "./edit_hotel.vue";
import { hotelList } from "@/api/shopSystem";
export default {
  components: { Pagination, Detail, Edit },
  data() {
    return {
      loading: true,
      orderId: "",
      time: "",
      dialogVisible: false,
      editDialog: false, //编辑
      page: {
        total: 0,
        pageNum: 1, // 当前页数
        pageSize: 10, // 每页的条数
      },
      title: "",
      deliverId: "",
      deliverArr: [
        { id: 0, name: "全部" },
        { id: 1, name: "待支付" },
        { id: 2, name: "待发货" },
        { id: 3, name: "待收货" },
      ],
      tableData: [],
      rowData: {}, //当前行数据 传给详情
    };
  },
  methods: {
    //订单列表
    async hotelList() {
      const { data, err } = await hotelList({
        page: this.page.pageNum,
      });
      if (err === 0) {
        this.loading = false;
        this.tableData = data.data;
        this.page.pageSize = data.per_page;
        this.page.total = data.total;
      }
    },
    //查询
    handleQuery() {
      this.loading = true;
      //调接口
      this.page.pageNum = 1;
      this.hotelList();
    },
    //查看详情
    handleDetail(row) {
      this.dialogVisible = true;
      this.title = "编辑";
      this.rowData = row;
    },
    handleCurrentChange(val) {
      this.page.pageNum = 1;
      this.hotelList();
    },
    //编辑
    handleEdit(row) {
      this.editDialog = true;
      this.rowData = row;
      this.title = "编辑";
    },
    handleClose() {
      this.editDialog = false;
      this.hotelList();
    },
  },
  created() {
    this.hotelList();
  },
};
</script>

<style lang="scss" scoped>
@import "@/style/index.scss";
.hotel_info {
  text-align: start;
}
.info {
  .title {
    font-size: 16px;
    margin-bottom: 13px;
  }
}
.pagination {
  display: flex;
  justify-content: flex-end;
  padding-top: 10px;
}
.el-select {
  width: 100%;
}

.tb {
  background-color: #fff;
  padding: 20px;
  box-sizing: border-box;
}
.row {
  display: flex;
  border-radius: 2px;
  border: 1px solid #ccc;
  width: 80px;
  .l {
    width: 80px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;

    i {
      margin-right: 6px;
      font-size: 18px;
    }
    &:hover {
      cursor: pointer;
    }
  }
  .l:nth-child(3) {
    border-right: 0;
  }
}
.editDialog {
  //   z-index: 2005 !important;
  /deep/.el-dialog {
    height: 75%;
    .el-dialog__body {
      height: 78%;
      overflow: auto;
    }
  }
}
.handleEdit {
  margin-left: 20px;
}
</style>
